/*************************************************************************
	> File Name: Util.hpp
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/10/24 20:09
 ************************************************************************/

#pragma once

#include <iostream>
#include <vector>

class Util
{
public:
    static void cutString(std::string s, const std::string& sep, std::vector<std::string>* out)
    {
        size_t start = 0;
        while (start < s.size()) {
            auto pos = s.find(sep, start);
            if (pos == std::string::npos) {
                break;
            }
            std::string sub = s.substr(start, pos - start);
            out->push_back(sub);
            start += sub.size();
            start += sep.size();
        }
        if (start < s.size()) {
            out->push_back(s.substr(start));
        }
    }
};
